cmake_minimum_required(VERSION 3.5)
project(fake_odom)

# 编译选项应该在项目开始时设置
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 17)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(CMAKE_BUILD_TYPE Release)

# 查找所有需要的包
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_eigen REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(agv_msgs REQUIRED)

# 包含目录
include_directories(
  include
  ${EIGEN3_INCLUDE_DIRS}
)

# 创建可执行文件
add_executable(fake_odom_node 
  src/fake_odom/fake_odom_node.cpp
  src/fake_odom/FakeOdometry.cpp
)

# 添加依赖
ament_target_dependencies(fake_odom_node
  rclcpp
  tf2
  tf2_ros
  tf2_eigen
  tf2_geometry_msgs
  geometry_msgs
  agv_msgs
)

# 安装目标
install(TARGETS
  fake_odom_node
  DESTINATION lib/${PROJECT_NAME}
)

# 安装头文件和其他资源
install(DIRECTORY
  include/
  DESTINATION include/${PROJECT_NAME}
)

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/launch)
  install(DIRECTORY
    launch/
    DESTINATION share/${PROJECT_NAME}/launch
  )
endif()

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/config)
  install(DIRECTORY
    config/
    DESTINATION share/${PROJECT_NAME}/config
  )
endif()

# 导出依赖
ament_export_include_directories(include)
ament_export_dependencies(
  rclcpp
  tf2
  tf2_ros
  tf2_eigen
  tf2_geometry_msgs
  geometry_msgs
  agv_msgs
)

ament_package()